package gc;import java.util.ArrayList;import java.util.List;/** * @Author: Beating Pupils * @Date: 2020/7/29 08:12 * @Description: 演示堆内存溢出：设置堆内存10M,测试跑了360145次发生了 java.lang.OutOfMemoryError: Java heap space */public class OOM2 {    public static long counter = 0;    public static void main(String[] args) {        List<Object> list = new ArrayList<>();        while (true){            list.add(new MinorGCTest());            System.out.println("目前是第"+ (++counter) +"次创建对象");        }    }}